package gr.unipi.mscd1;

public class IfInfo extends SnmpGenInfo {
	private int id;
	private String descr;
	private String physAddr;
	private int linkType;
	private int mtu;
	private int speed;
	private int operStatus;
	private long trafficIn;
	private long trafficOut;
	private long discardsIn;
	private long discardsOut;
	
	public IfInfo(InterfaceInfo newInfo) {
		this.id = (Integer) newInfo.getOids().get(0).getValue();
		this.descr = newInfo.getOids().get(1).getValue().toString();
		this.physAddr = newInfo.getOids().get(2).getValue().toString();
		this.linkType = (Integer) newInfo.getOids().get(3).getValue();
		this.mtu = (Integer) newInfo.getOids().get(4).getValue();
		this.speed = (Integer) newInfo.getOids().get(5).getValue();
		this.operStatus = (Integer) newInfo.getOids().get(6).getValue();
		this.trafficIn = (Long) newInfo.getOids().get(7).getValue();
		this.trafficOut = (Long) newInfo.getOids().get(8).getValue();
		this.discardsIn = (Long) newInfo.getOids().get(9).getValue();
		this.discardsOut = (Long) newInfo.getOids().get(10).getValue();
	}
	

	public int getId() {
		return id;
	}
	
	public String getDescr() {
		return descr;
	}
	
	public String getPhysAddr() {
		return physAddr;
	}
	
	public int getLinkType() {
		return linkType;
	}
	
	public String getLinkTypeDescr() {
		if (!typesDescr.containsKey(linkType)) {
			return linkType + "";
		}
		return typesDescr.get(linkType) + "(" + linkType + ")";
	}
	
	public int getMtu() {
		return mtu;
	}
	
	public int getSpeed() {
		return speed;
	}
	
	public int getSpeedInBytes() {
		return speed / 8;
	}
	
	public int getOperStatus() {
		return operStatus;
	}
	
	public String getOperStatusDescr() {
		return operDescr.get(operStatus);
	}

	public long getTrafficIn() {
		return trafficIn;
	}
	
	public long getTrafficOut() {
		return trafficOut;
	}
	
	public long getSumTraffic() {
		return trafficIn + trafficOut;
	}

	public long getDiscardsIn() {
		return discardsIn;
	}

	public long getDiscardsOut() {
		return discardsOut;
	}
	
	public long getDiscardsSum() {
		return getDiscardsOut() + getDiscardsIn();
	}
}
